package com.unohacha.qqj.fzdr.adapter;

import android.view.View;
import android.widget.ImageView;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.unohacha.qqj.fzdr.R;
import com.unohacha.qqj.fzdr.bean.SysMessage;
import com.unohacha.qqj.fzdr.bean.SysPuthBean;
import com.unohacha.qqj.fzdr.ui.activity.SysMessageActivity;

import java.util.List;

public class SysMessageAdapter extends BaseQuickAdapter<SysMessage, BaseViewHolder> {
    private boolean isShow=false;
    public SysMessageAdapter(List<SysMessage> data) {
        super(R.layout.item_sys_message, data);

    }

    @Override
    protected void convert(final BaseViewHolder helper, final SysMessage pubMatchData) {
//        Glide.with(mContext).load(pubMatchData.getList_pic()).into((ImageView) helper.getView(R.id.store_pic));
        helper.setText(R.id.tv_time,pubMatchData.getDate()+"");
        helper.setText(R.id.tv_content,pubMatchData.getContent());
        if(isShow){
            ((ImageView)helper.getView(R.id.img_select)).setVisibility(View.VISIBLE);
        }else {
            ((ImageView)helper.getView(R.id.img_select)).setVisibility(View.GONE);
        }

        if (pubMatchData.isChecked()){
            ((ImageView)helper.getView(R.id.img_select)).setBackgroundResource(R.mipmap.xuanzhong);
        }else{
            ((ImageView)helper.getView(R.id.img_select)).setBackgroundResource(R.mipmap.weixuanzhong);
        }
        helper.getView(R.id.img_select).setOnClickListener(new OnCheckClicklistener(helper.getLayoutPosition()));
    }
    public void setIsShowImg(boolean isShow){
        this.isShow=isShow;
    }
    public class OnCheckClicklistener implements View.OnClickListener{
        public int position;

        public OnCheckClicklistener(int position) {
            this.position = position;
        }

        @Override
        public void onClick(View view) {
            //改变activity数据
            if ( mContext instanceof SysMessageActivity){
                SysMessageActivity  activity= (SysMessageActivity) mContext;
                activity.isChecklist(position);
            }
        }
    }
}
